{% extends "personal_center/base.html" %}

{% block page_link %}
    <link rel="stylesheet" href="../../static/system_setup/css/style.css">
    <link rel="stylesheet" type="text/css" href="../../static/personal_center/css/index.css">
    <link rel="stylesheet" type="text/css" href="../../static/personal_center/css/common.css">
    <script type="text/javascript" src="../../static/personal_center/js/index.js"></script>
{% endblock %}


{% block style %}
    <style>
        .add_class {
            background: #1E90FF;
        }
        .model_li {
            color: #3f414d;width: 25%;cursor: pointer;display: none;
        }
        .top_tag {
            border-bottom: #01AAED solid 2px;color: #01AAED;
        }
        .tab_top {
            width: 100px;height: 40px;line-height: 40px;text-align: center;display: inline-block;cursor: pointer;
        }
        .shade {
            position: fixed;top: 0;left: 0;right: 0;bottom: 0;background-color: rgba(36, 36, 36, 0.5);display: none;z-index: 10000;
        }
        .div_style {
            width: 100%;height: 40px;line-height: 40px;padding-left: 20px;cursor: pointer;overflow: hidden;text-overflow:ellipsis;white-space: nowrap;
        }
        .div_style_background{
            background: #00a0e9;color: white;
        }
        .year-nav {
            padding-left: 10px;width: 100%;height: 35px;line-height: 35px;cursor: pointer;background: #cfcfcf;border-bottom: white dashed 1px;
        }
        .number-nav {
            padding-left: 30px;width: 100%;height: 35px;line-height: 35px;cursor: pointer;border-bottom: #cfcfcf dashed 1px;
        }
        .add-color {
            color: blue;
        }
        .year_meet_nav:hover {
            background: #cecece;color: #0b0b0b;
        }
        .year_meet_nav {
            width: 100%;height: 35px;line-height: 35px;border-bottom: #cecece dashed 1px;padding-left: 2%;cursor: pointer;
        }
        .year_meet_nav_active {
            background: #2db7f5;color: white;
        }
        .frequency:hover {
            background: #cecece;
        }
        .frequency {
            width: 100%;height: 35px;cursor: pointer;border-bottom: #cecece dashed 1px;line-height: 35px;padding-left: 10%;font-size: 13.5px;
        }
        .frequency_active {
            background: #2db7f5;color: white;
        }
        .file {
            position: relative;display: inline-block;background: #D0EEFF;border: 1px solid #99D3F5;border-radius: 4px;padding: 4px 12px;overflow: hidden;color: #1E88C7;text-decoration: none;text-indent: 0;line-height: 20px;margin-top: -15px;
        }
        .file input {
            position: absolute;font-size: 100px;right: 0;top: 0;opacity: 0;
        }
        .file:hover {
            background: #AADFFD;border-color: #78C3F3;color: #004974;text-decoration: none;
        }
    </style>
{% endblock %}


{% block right_content %}
    <div class="headline">
        <div id="my_application_tab" onclick="change_mind('yb')" class="{% if topic_type == 'yb' %}tab_top top_tag{% else %}tab_top{% endif %}">
            院办议题
        </div>
        <div id="new_issues_tab" onclick="change_mind('db')" class="{% if topic_type == 'db' %}tab_top top_tag{% else %}tab_top{% endif %}">
            党办议题
        </div>
        <div id="administrative_meetings_tab" onclick="change_mind('xz')" class="{% if topic_type == 'xz' %}tab_top top_tag{% else %}tab_top{% endif %}">
            行政例会
        </div>

        <div style="float: right;width: 50%;height: 100%;text-align: right;font-size: 0;padding-top: 5px;padding-right: 10px;" id="search-div">
            <button onclick="minutes_online()" style="width: 100px;height: 30px;border-radius: 3px;border: #0c6fd9 solid 1px;background: #0c6fd9;color: white;margin-right: 20px;font-size: 14px;">上传会议纪要</button>
            <input type="text" id="search_value" name="search_val" style="border: #0d8ddb solid 1px;border-top-left-radius: 3px;border-bottom-left-radius: 3px;display: inline-block;width: 300px;height: 30px;outline: none;vertical-align: top;font-size: 14px;" placeholder="请输入搜索关键词">
            <button class="search-action" style="border-top-right-radius: 3px;border-bottom-right-radius: 3px;width: 100px;height: 30px;border: #0d8ddb;border-left: none;background: #0d8ddb;color: white;vertical-align: top;margin-left: -1px;font-size: 14px;line-height: 30px;">搜索</button>
        </div>
    </div>

    <div id="upload_meeting_minutes" class="shade">
        <div id="meeting_minutes" style="width: 100%;height: 100%;position: absolute;">
            <div style="width: 400px;background: #F5F5F5;z-index: 10000;position: absolute;top: 50%;left: 50%;transform:translate(-50%,-50%);border-radius: 3px;border: #dfdfdf solid 1px;">
                <div id="minutes" style="width: 400px;height: 40px;background: #f4f7fa;cursor: move;border-top-left-radius: 5px;border-top-right-radius: 5px;border-bottom: #cfcfcf solid 1px;">
                    <h6 class="modal-title" style="line-height: 40px;width: 35%;margin-left: 1%;display: inline-block;">上传会议纪要</h6>
                    <span onclick="close_models3()" style="float: right;line-height: 40px;padding-right: 2%;cursor: pointer;"><i class="iconfont icon-quchu"></i></span>
                </div>

                <div style="width: 400px;border-bottom: #cfcfcf solid 1px;padding-bottom: 20px;">
                    <div style="padding-left: 15px;margin-top: 15px;">
                        <label for="">会议类型：</label>
                        <select name="" id="TopicType" style="width: 250px;height: 30px;border: #999999 solid 1px;outline: none;border-radius: 3px;">
                            <option value="">请选择会议类型</option>
                            <option value="yb">院长办公会</option>
                            <option value="db">党委会</option>
                        </select>
                    </div>

                    <div style="padding-left: 15px;margin-top: 15px;">
                        <label for="">会议年份：</label>
                        <input type="number" id="MeetYear" style="width: 250px;height: 30px;border: #999999 solid 1px;outline: none;border-radius: 3px;" placeholder="只能填写数字">
                    </div>

                    <div style="padding-left: 15px;margin-top: 15px;">
                        <label for="">会议次数：</label>
                        <input type="number" id="MeetNumber" style="width: 250px;height: 30px;border: #999999 solid 1px;outline: none;border-radius: 3px;" placeholder="只能填写数字">
                    </div>

                    <div style="padding-left: 15px;margin-top: 30px;">
                        <label for="">会议纪要：</label>
                        <div style="margin-left: 2%;width: 70%;height: 40px;display: inline-block;">
                            <div style="width: 40px;height: 40px;display: inline-block;vertical-align: top;">
                                <a href="javascript:;" class="file">
                                    <img src="../../static/personal_center/img/加号_o.png" alt="" onclick="onclick_upload_file()" style="width: 40px;height: 40px;vertical-align: baseline;">
                                    <input type="file" name="regular_main_body" id="regular_main_body" onchange="upload_accessory('file1', 'regular_main', 'regular_main_body')">
                                </a>
                            </div>

                            <div id="upload_file_list" style="width: 76%;height: 100%;display: inline-block;vertical-align: top;">

                            </div>
                        </div>
                    </div>
                </div>

                <div style="width: 400px;height: 40px;text-align: right;padding-right: 2%;">
                    <button id="SubmitSummary" onclick="submit_summary()" style="width: 100px;height: 30px;border: #dfdfdf solid 1px;border-radius: 3px;background: #1E90FF;color: white;margin-top: 5px;">
                        提交
                    </button>
                </div>
            </div>
        </div>
    </div>

    <div id="my_application" style="width: 100%;height: 95%;overflow: auto;background-color: white;">
        <div id="" style="width: 100%;height: 100%;">
            <div id="yisanghui" style="width: 100%;height: 100%;overflow: auto;font-size: 0;">
                <div id="The_navigation" style="display: inline-block;width: 15%;vertical-align: top;height: 99%;margin-top: 0;font-size: 16px;overflow: auto;border-right: #cecece solid 1px;">
                    {% for datas in LeftDict %}
                        {% for keys, val in datas.items %}
                            {% if keys != 'open' %}
                                <div class="{% if datas.open == 'true' %}year_meet_nav year_meet_nav_active{% else %}year_meet_nav{% endif %}" onclick="ChoiceLeftNav(this, '{{ keys }}')">
                                    {{ keys }}
                                </div>
                                <div class="meet_list_div" id="{{ keys }}" style="width: 100%;{% if datas.open != 'true' %} display: none; {% endif %}">
                                    {% for foo in val %}
                                        <div id="{{ foo.year }}_{{ foo.number }}" class="{% if foo.choose == 'true' %}frequency frequency_active{% else %}frequency{% endif %}" onclick="change_color(this, '{{ foo.year }}', '{{ foo.number }}')">
                                            {{ foo.name }}
                                        </div>
                                    {% endfor %}
                                </div>
                            {% endif %}

                        {% endfor %}
                    {% endfor %}
                </div>
                <div class="right-box" style="display: inline-block;width: 84.8%;vertical-align: top;height: 100%;margin-top: 0;">
                    <div style="width: 100%;height: 100%;display: inline-block;vertical-align: top;background: white;">
                        <div style="height: 100%;width: 100%;overflow: auto;background-color: white;border-bottom: #cfcfcf solid 1px;">
                            <section class="grid-main" style="height: 100%;">
                                <table id="has-meeting"></table>
                            </section>
                        </div>
                    </div>
                </div>
            </div>

            <div id="new_models2" class="shade">
                <div id="new_models3" style="width: 100%;height: 100%;position: absolute;">
                    <div style="width: 600px;background: #F5F5F5;z-index: 10000;position: absolute;top: 50%;left: 50%;transform:translate(-50%,-50%);border-radius: 3px;border: #dfdfdf solid 1px;">
                        <div id="box2" style="width: 100%;height: 50px;background: #f4f7fa;cursor: move;border-top-left-radius: 5px;border-top-right-radius: 5px;">
                            <h5 id="modal-title2" class="modal-title"
                                style="line-height: 50px;width: 15%;margin-left: 1%;display: inline-block;">会议结果</h5>
                            <span onclick="close_models2()" style="float: right;line-height: 50px;padding-right: 2%;cursor: pointer;"><i class="iconfont icon-quchu"></i></span>
                        </div>
                        <hr>

                        <div style="width: 100%;">
                            <div style="padding-left: 15px;margin-top: 15px;">
                                <input type="radio" name="check1" onclick="disp_peo1(1)" value="audit"> 通过
                                <input type="radio" name="check1" style="margin-left: 3%;" value="draft" onclick="disp_peo1(2)"> 不通过
                            </div>

                            {% if topic_type == 'yb' %}
                                <div style="padding-left: 15px;margin-top: 15px;">
                                    <label for="">是否转会：</label><input type="radio" name="transfer_or_not" value="1"> 是<input type="radio" name="transfer_or_not" style="margin-left: 15px" value="0" checked> 否</span>
                                </div>
                            {% endif %}

                            <div style="padding-left: 15px;margin-top: 15px;">
                                <div style="width: 100%;height: 40px;line-height: 40px;">
                                    <label for="">议题名称：</label><span id="topic_title"></span>
                                </div>
                                <div style="width: 100%;height: 40px;line-height: 40px;">
                                    <label for="">议题编号：</label><span id="topic_number"></span>
                                </div>
                            </div>

                            <div id="reject_cancel" style="padding-left: 15px;margin-top: 15px;display: none;">
                                <input type="radio" name="check2" value="draft"> 驳回修改
                                <input type="radio" name="check2" style="margin-left: 3%;" value="unaudit" > 议题作废
                            </div>

                            <div style="margin-top: 15px;padding-left: 15px;">
                                <label style="vertical-align: top;">会议意见：</label>
                                <textarea name="" id="opinion_detail_fg" cols="30" rows="2" style="width: 95%;border: #cfcfcf solid 1px;outline: none;"></textarea>
                            </div>
                        </div>

                        <hr>
                        <div style="width: 100%;height: 40px;text-align: right;padding-right: 2%;">
                            <button id="button"  style="width: 100px;height: 30px;border: #dfdfdf solid 1px;border-radius: 3px;background: #1E90FF;color: white;margin-top: 5px;">
                                提交
                            </button>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
{% endblock %}

{% block script %}
    <script type="text/javascript" src="../../static/personal_center/js/other/jquery.js"></script>
    <script src="../../static/administrative/layDate-v5.0.9/laydate/laydate.js"></script> <!-- 改成你的路径 -->
    <script>
        window.onload = function () {
            document.getElementById("loading").style.display = "none";
            document.getElementById("personage").className = "add_class";
            document.getElementById("sponsor").className = "add-nav-active";
            HasMeeting('{{ choose_year | safe }}', '{{ choose_number | safe }}');
        };

        let title = document.querySelector("#box2");
        let addForm = document.querySelector("#new_models3");

        title.addEventListener("mousedown", function (e) {
            let x = e.pageX - addForm.offsetLeft;
            let y = e.pageY - addForm.offsetTop;

            document.addEventListener("mousemove", move);
            function move(e) {
                addForm.style.left = e.pageX - x + 'px';
                addForm.style.top = e.pageY - y + 'px';
            }

            document.addEventListener("mouseup", function (e) {
                document.removeEventListener("mousemove", move);
            })
        });

        let minutes = document.querySelector("#minutes");
        let meeting_minutes = document.querySelector("#meeting_minutes");

        minutes.addEventListener("mousedown", function (e) {
            let x = e.pageX - meeting_minutes.offsetLeft;
            let y = e.pageY - meeting_minutes.offsetTop;

            document.addEventListener("mousemove", move);
            function move(e) {
                meeting_minutes.style.left = e.pageX - x + 'px';
                meeting_minutes.style.top = e.pageY - y + 'px';
            }

            document.addEventListener("mouseup", function (e) {
                document.removeEventListener("mousemove", move);
            })
        });

        function disp_peo1(chose_type) {
            if (chose_type === 1){
                document.getElementById("reject_cancel").style.display='none';
            }else {
                document.getElementById("reject_cancel").style.display='block';
            }
        }

        function close_models2() {
            document.getElementById("new_models2").style.display = "none";
        }

        function minutes_online() {
            document.getElementById("upload_meeting_minutes").style.display = "table-row";
        }

        function close_models3() {
            document.getElementById("upload_meeting_minutes").style.display = "none";
        }

        function online_tag1(id, type, title, IssueNumber) {
            document.getElementById("topic_title").innerText = title;
            document.getElementById("topic_number").innerText = IssueNumber;
            document.getElementById("new_models2").style.display = "table-row";
            document.getElementById("button").setAttribute("onclick", "audit('"+id+"')")
            document.getElementById("reject_cancel").style.display = "none";
            var check_obj = document.getElementsByName("check1");
            var check1_obj = document.getElementsByName("check2");
            for (var jj=0; jj<check_obj.length; jj++) {
                check_obj[jj].checked = false
            }
            for (var kk=0; kk<check1_obj.length; kk++) {
                check1_obj[kk].checked = false
            }
        }

        var returnData = {{ returnData | safe }};
        var permissions = {{ permissions | safe }};
        function change_mind(ele_id) {
            if (ele_id === "yb") {
                if (!permissions['院办议题']){
                    alert("您的访问权限不足!");
                    return false
                 }
                window.location.href = "topic_discussion.html?type=yb";
            } else if (ele_id === "db"){
                if (!permissions['党办议题']){
                    alert("您的访问权限不足!");
                    return false
                 }
                window.location.href = "topic_discussion.html?type=db";
            }else {
                if (!permissions['行政例会']){
                    alert("您的访问权限不足!");
                    return false
                 }
                window.location.href = "topic_discussion.html?type=xz";
            }
        }

        function audit(ele_id, eval_id) {
            var TopicType = '{{ topic_type | safe }}';
            var TransferOrNot = ""
            if (TopicType === 'yb') {
                TransferOrNot = $("input[type=radio][name=transfer_or_not]:checked").val();
            }
            var opinion_detail_fg = document.getElementById("opinion_detail_fg").value;
            var audit_result = $("input[type=radio][name=check1]:checked").val();

            var reject_cancel = "";
            if (!audit_result) {
                alert("请选择会议结果！")
                return  false
            }

            if (audit_result === "draft"){
                audit_result = $("input[type=radio][name=check2]:checked").val();
            }

            if (TopicType === 'db' && !opinion_detail_fg) {
                alert("请填写会议结果！")
                return false
            }

            document.getElementById("loading").style.display = "inline-block";
            var xhr = new XMLHttpRequest();
            var local_host = window.location.host;          // 获取当前IP
            xhr.open('post', "/administrative/topics_result");
            xhr.setRequestHeader('content-type', 'application/x-www-form-urlencoded');
            xhr.setRequestHeader('Access-Control-Allow-Origin', '*');
            xhr.send("id="+ele_id+"&uuid={{ uuid }}&state="+String(audit_result)+"&audit_note="+String(opinion_detail_fg)+"&TransferOrNot="+TransferOrNot);
            xhr.onreadystatechange = function () {
                if (xhr.readyState === 4) {
                    if (xhr.status === 200) {
                        close_models2();
                        document.getElementById("loading").style.display = "none";
                        var JsonDate = JSON.parse(xhr.responseText);
                        if (JsonDate["code"] === 200){
                            document.getElementById(ele_id).style.color="#727E8C";
                            document.getElementById(ele_id).removeAttribute("onclick");
                            if (TransferOrNot === '1') {
                                document.getElementById("transfer_"+ele_id).style.color='#727E8C';
                            }
                            alert("操作成功");
                        }else {
                            alert(JsonDate["message"]);
                        }
                    }
                }
             };
        }

        function Pagination(tic_type, meet_num, page, will_or_not) {
            // tic_type: 议题类型
            // will_or_not： 是否上会: 2:已上， 1：未上
            document.getElementById("loading").style.display = "inline-block";
            var xhr = new XMLHttpRequest();
            var local_host = window.location.host;          // 获取当前IP
            xhr.open('post', "/personal-center/summary_page");
            xhr.setRequestHeader('content-type', 'application/x-www-form-urlencoded');
            xhr.setRequestHeader('Access-Control-Allow-Origin', '*');
            xhr.send("tic_type="+tic_type+"&meet_num="+String(meet_num)+"&page="+String(page)+"&will_or_not="+String(will_or_not));
            xhr.onreadystatechange = function () {
                if (xhr.readyState === 4) {
                    if (xhr.status === 200) {
                        document.getElementById("loading").style.display = "none";
                        var JsonDate = JSON.parse(xhr.responseText);
                        console.log(JsonDate)
                        if (will_or_not === 'b'){
                            create_shanghui(JsonDate["data"], meet_num, tic_type);
                            pagenum(JsonDate["data_len"], page, tic_type, meet_num, will_or_not);
                        }else {
                            create_weishang(JsonDate["data"], tic_type)
                            pagenum1(JsonDate["data_len"], tic_type, '0', will_or_not, page);
                        }
                    }
                }
             };
        }

        function pass_yb(tic_id) {
            document.getElementById("loading").style.display = "inline-block";
            var is_yb = "";
            if (document.getElementById(tic_id).checked){
                is_yb = true;
            }
            var xhr = new XMLHttpRequest();
            var local_host = window.location.host;          // 获取当前IP
            xhr.open('post', "/personal-center/pass_yb", true);
            xhr.setRequestHeader('content-type', 'application/x-www-form-urlencoded');
            xhr.send("tic_id="+String(tic_id.replace("CC-", ''))+"&is_yb="+String(is_yb));
            xhr.onload = function () {
                if (xhr.status === 200) {
                    document.getElementById("loading").style.display = "none";
                    alert("修改成功！")
                }
             };
        }

        function ChoiceLeftNav(this_obj, ele_id) {
            if (this_obj.className === 'year_meet_nav year_meet_nav_active') {
                if (document.getElementById(ele_id).style.display==="none"){
                    document.getElementById(ele_id).style.display="block";
                }else {
                    document.getElementById(ele_id).style.display="none"
                }
                return false
            }

            var YearMeetNavList = document.getElementsByClassName("year_meet_nav");
            for (var i=0; i<YearMeetNavList.length; i++) {
                YearMeetNavList[i].className = "year_meet_nav";
            }
            this_obj.className = "year_meet_nav year_meet_nav_active"

            var MeetListDiv = document.getElementsByClassName("meet_list_div");
            for (var j=0; j<MeetListDiv.length; j++) {
                MeetListDiv[j].style.display = "none";
            }

            if (document.getElementById(ele_id).style.display==="none"){
                document.getElementById(ele_id).style.display="block";
            }else {
                document.getElementById(ele_id).style.display="none"
            }
        }
        
        function HasMeeting(choose_year, choose_number) {
            const gridManagerName = "test",
            arg = {
                gridManagerName: "test",
                width: "100%",
                height: "100%",
                autoOrderConfig: {fixed: "left"},
                checkboxConfig: {key: "id", fixed: "left"},
                supportAjaxPage: !0,
                sortMode: "single",
                supportMenu: !0,
                menuHandler: e => (e.unshift({
                    content: "自定义菜单", line: !0, onClick: e => {
                    }
                }), e),
                useCellFocus: !0,
                useHideRow: !0,
                supportMoveRow: !0,
                moveRowConfig: {
                    key: "priority", useSingleMode: !0, fixed: "left", handler: (e, t) => {
                        console.log(e, t)
                    }
                },
                disableCache: !1,
                ajaxData: function (e, t) {
                    var local_host = window.location.host;          // 获取当前IP
                    t["iss_type"] = "{{ topic_type | safe }}";
                    t["iss_number"] = choose_number;
                    t["IssYesr"] = choose_year;
                    return "/personal-center/GetIssList"
                },
                exportConfig: {
                    fileName: e => {
                        const t = new Date;
                        let a = `${t.getFullYear()}-${t.getMonth() + 1}-${t.getDate()}`;
                        for (let t in e) a = `${a}-${t}=${e[t]}`;
                        return a
                    }, suffix: "xls"
                },
                ajaxType: "POST",
                checkedBefore: function (e, t, a) {
                    return console.log("checkedBefore==", e, t, a), a && 90 === a.id && alert("该节点在checkedBefore中配置为不可选"), a && 90 !== a.id
                },
                ajaxSuccess: function (e) {
                    console.log("===================", JSON.parse(e)["LeftDict"])
                    if (JSON.stringify(JSON.parse(e)["LeftDict"]) !== "{}"){

                        create_left_nav(JSON.parse(e)["LeftDict"], iss_type)
                    }
                },
                ajaxBeforeSend: function (e, t) {
                    console.log("ajaxBeforeSend: ", t)
                },
                ajaxError: function (e) {
                    console.log("ajaxError")
                },
                ajaxComplete: function (e) {
                    console.log("ajaxComplete")
                },
                adjustBefore: e => {
                    console.log("adjustBefore=>", e)
                },
                adjustAfter: e => {
                    console.log("adjustAfter=>", e)
                },
                responseHandler: e => (e.data.forEach((e => {
                    e.priority = e.id
                })), e),
                rowRenderHandler: (e, t) => e,
                emptyTemplate: e => `<div style="text-align: center;">${e.query.title ? "搜索为空" : "暂无数据"}</div>`,
                columnData: [{
                    key: "title",
                    text: "议题名称",
                    disableMoveRow: !0
                }, {
                    key: "IssueNumber",
                    text: "议题编号",
                    align: "center",
                    // sorting: "",
                    disableMoveRow: !0,
                }, {
                    key: "department",
                    text: "提交科室",
                    align: "center",
                    disableMoveRow: !0
                }, {
                    key: "submitter",
                    text: "提交人",
                    align: "center",
                }, {
                    key: "SubmissionTime",
                    text: "提交时间",
                    align: "center",
                }, {
                    key: "action",
                    width: "250px",
                    align: "center",
                    fixed: "right",
                    disableMoveRow: !0,
                    disableRowCheck: !0,
                    text: '<span style="color: red">操作</span>',
                    template: (e, t) => `<a class="plugin-action" href="#" onclick="javascript;:">${t.url}</a>`
                }
            ]
            }, demo1 = {
                initSearch: function () {
                    document.querySelector(".search-action").addEventListener("click", (function () {
                        var iss_type = document.getElementsByClassName('frequency frequency_active')[0].id;

                        var e = {
                            iss_type: '{{ topic_type }}',
                            search_val: document.querySelector('[name="search_val"]').value,
                            iss_number: iss_type.split("_")[1],
                            IssYesr: iss_type.split("_")[0]
                        };
                        table.GM("setQuery", e, (function () {
                            console.log("setQuery执行成功")
                        }))
                     }))
                }, initFN: () => {

                }, initGM: function () {
                    new window.GridManager(table, arg, (e => {
                        console.log("渲染完成后的回调函数:", e), console.log(arg.columnData)
                        var check_list = document.getElementsByClassName("display_none");
                        for (var i=0; i<check_list.length; i++) {
                            check_list[i].setAttribute("readonly", "ture");
                        }
                    }))
                }, editRowData: function (e) {
                    window.GridManager.updateRowData("test", "id", {
                        id: window.parseInt(e.getAttribute("data-id")),
                        lastDate: (new Date).getTime()
                    })
                }
            }, table = document.getElementById("has-meeting");
            demo1.initSearch(table), demo1.initGM(table), demo1.initFN();
        }

        function change_color(this_obj, choose_year, choose_number) {
            var FrequencyList = document.getElementsByClassName("frequency");
            for (var i=0; i<FrequencyList.length; i++) {
                FrequencyList[i].className = "frequency"
            }
            this_obj.className = "frequency frequency_active";
            HasMeeting(choose_year, choose_number);
        }

        function create_left_nav(json_data, iss_type) {
            var The_navigation = document.getElementById("The_navigation");
            The_navigation.innerHTML = "";
            for (key in json_data) {
                var divTag = document.createElement("div");divTag.setAttribute("onclick", "ChoiceLeftNav('"+key+"')");divTag.className='year-nav'
                if (iss_type === 'yb') {
                    divTag.innerText = String(key) + "年院长办公会";
                }else if (iss_type === 'db') {
                    divTag.innerText = String(key) + "年党委会";
                }else {
                    divTag.innerText = String(key) + "年行政例会";
                }
                The_navigation.appendChild(divTag);
                var divTag1 = document.createElement("div");divTag1.id = key;divTag1.style.width="100%";divTag1.style.maxHeight=""
                if (json_data[key]["open"]) {
                    for (var foo=0; foo<json_data[key]["NumberList"].length; foo++) {
                        var divTag2 = document.createElement("div");divTag2.setAttribute("onclick", "change_color(this)");divTag2.className = "number-nav";
                        if (foo === 0) {
                            divTag2.className = "number-nav add-color";
                        }
                        if (iss_type === 'yb') {
                            divTag2.innerText = String(key) + "年第" + String(json_data[key]["NumberList"][foo]) + "次院长办公会";
                        }else if (iss_type === 'db') {
                            divTag2.innerText = String(key) + "年第" + String(json_data[key]["NumberList"][foo]) + "次党委会";
                        }else {
                            divTag2.innerText = String(key) + "年第" + String(json_data[key]["NumberList"][foo]) + "次行政例会";
                        }
                        divTag1.appendChild(divTag2);
                    }
                }else {
                    divTag1.style.display='none';
                    for (var foo1=0; foo1<json_data[key]["NumberList"].length; foo1++) {
                        var divTag3 = document.createElement("div");divTag3.setAttribute("onclick", "change_color(this)");divTag3.className = "number-nav";
                        if (iss_type === 'yb') {
                            divTag3.innerText = String(key) + "年第" + String(json_data[key]["NumberList"][foo1]) + "次院长办公会";
                        }else if (iss_type === 'db') {
                            divTag3.innerText = String(key) + "年第" + String(json_data[key]["NumberList"][foo1]) + "次党委会";
                        }else {
                            divTag3.innerText = String(key) + "年第" + String(json_data[key]["NumberList"][foo1]) + "次行政例会";
                        }
                        divTag1.appendChild(divTag3);
                    }
                }
                The_navigation.appendChild(divTag1);
            }
        }

        // 议题转会：院长办公会转党委会
        function ajax_request(ele_id, eve, title, IssueNumber) {

            var sour_type = confirm("议题名称："+title+"\n"+"议题编号："+IssueNumber+"\n"+"是否直接将该议题转党委会？")
            if (sour_type) {
                document.getElementById("loading").style.display = "inline-block";
                var xhr = new XMLHttpRequest();
                var local_host = window.location.host;          // 获取当前IP
                xhr.open('post', "/administrative/TopicsView", true);
                xhr.setRequestHeader('content-type', 'application/x-www-form-urlencoded');
                xhr.send("id="+String(ele_id)+"&transfer=true");
                xhr.onreadystatechange = function () {
                    if (xhr.readyState === 4) {
                        if (xhr.status === 200) {
                            document.getElementById("loading").style.display = "none";
                            var JsonDate = JSON.parse(xhr.responseText);
                            console.log(JsonDate);
                            if (JsonDate["code"] === 200){
                                alert("操作成功！");
                                eve.style.color='#727E8C';
                                eve.removeAttribute("onclick");
                            }else {
                                alert(JsonDate["message"]);
                            }
                        }
                    }
                 };
            }
        }

        function onclick_upload_file() {
            document.getElementById("regular_main_body").click();
        }

        function upload_accessory(file_type, tbody_id, accessory_type) {
            document.getElementById("loading").style.display = "inline-block";
            var form = new FormData();
            var files = document.getElementById(accessory_type).files[0];
            form.append(file_type, files);
            form.append('number', "{{ uuid | safe }}")
            form.append('source', 'hyjy')
            var xhr = new XMLHttpRequest();
            var local_host = window.location.host;          // 获取当前IP
            xhr.open('post', "/administrative/topics_attachments_upload", true);
            xhr.send(form);
            xhr.onreadystatechange = function () {
                if (xhr.readyState === 4) {
                    if (xhr.status === 200) {
                        document.getElementById("loading").style.display = "none";
                        var JsonDate = JSON.parse(xhr.responseText);
                        console.log(JsonDate);
                        creat_table(JsonDate, tbody_id)
                        document.getElementById("SubmitSummary").setAttribute("onclick", "submit_summary('"+JsonDate["id"]+"')")
                    }
                }
            };
        }

        // 创建附件列表
        function creat_table(JsonData, tbody_id) {
            if (Array.isArray(JsonData["pdf_path"])) {
                for (var i = 0; i < JsonData["pdf_path"].length; i++) {
                    var html_str = `
                        <div style="width: 100%;height: 40px;line-height: 40px;">
                            <div style="width: 79%;height: 100%;display: inline-block;vertical-align: top;overflow: hidden;white-space: nowrap;text-overflow: ellipsis;">
                                <a target='_blank' href="`+JsonData["pdf_path"][i]["pdf_path"]+`">`+JsonData["file_name"]+`</a>
                            </div>
                            <div onclick="RemoveTr(this, '`+JsonData["pdf_path"][i]["id"]+`')" style="width: 18%;height: 100%;display: inline-block;vertical-align: top;text-align: center;font-size: 12px;cursor: pointer;color: red;">
                                删除
                            </div>
                        </div>
                    `
                    $("#upload_file_list").append(html_str)
                }
            } else {
                html_str = `
                    <div style="width: 100%;height: 40px;line-height: 40px;">
                        <div style="width: 79%;height: 100%;display: inline-block;vertical-align: top;overflow: hidden;white-space: nowrap;text-overflow: ellipsis;">
                            <a target='_blank' href="`+JsonData["pdf_path"]+`">`+JsonData["file_name"]+`</a>
                        </div>
                        <div onclick="RemoveTr(this, '`+JsonData["id"]+`')" style="width: 18%;height: 100%;display: inline-block;vertical-align: top;text-align: center;font-size: 12px;cursor: pointer;color: red;">
                            删除
                        </div>
                    </div>
                `
                $("#upload_file_list").append(html_str)
            }
        }

        function RemoveTr(_this, tbody_id, wj_id) {
            //当前节点的父亲
            var parentNode = _this.parentNode;
            parentNode.remove()

            var xhr = new XMLHttpRequest();
            var local_host = window.location.host;          // 获取当前IP
            xhr.open('post', "/administrative/delete_attachments_view", true);
            xhr.setRequestHeader('content-type', 'application/x-www-form-urlencoded');
            xhr.send("id=" + String(wj_id));
            xhr.onreadystatechange = function () {
                if (xhr.readyState === 4) {
                    if (xhr.status === 200) {
                        document.getElementById("loading").style.display = "none";
                        var JsonDate = JSON.parse(xhr.responseText);
                        console.log(JsonDate);
                        alert("删除成功！")
                    }
                }
             };
        }

        function submit_summary(file_id='') {
            if (!file_id) {
                alert("请上传会议纪要!")
                return false
            }
            var TopicType = document.getElementById("TopicType").value;
            var MeetYear = document.getElementById("MeetYear").value;
            var MeetNumber = document.getElementById("MeetNumber").value;

            if (!TopicType) {
                alert("请选择会议类型!")
                return false
            }
            if (!MeetYear) {
                alert("请输入会议年份!")
                return false
            }
            if (!MeetNumber) {
                alert("请输入会议次数!")
                return false
            }
            document.getElementById("loading").style.display = "inline-block";
            var form = new FormData();
            form.append("file_id", file_id);
            form.append('TopicType', TopicType)
            form.append('MeetYear', MeetYear)
            form.append('MeetNumber', MeetNumber)
            var xhr = new XMLHttpRequest();
            xhr.open('post', "/administrative/UploadMeetingMinutes", true);
            xhr.send(form);
            xhr.onreadystatechange = function () {
                if (xhr.readyState === 4) {
                    if (xhr.status === 200) {
                        document.getElementById("loading").style.display = "none";
                        var JsonDate = JSON.parse(xhr.responseText);
                        console.log(JsonDate);
                        if (JsonDate["code"] === 200){
                            alert("上传成功！");
                        }else {
                            alert(JsonDate["message"]);
                        }
                    }
                }
            };
        }
    </script>
{% endblock %}
